require 'rubygems'
require 'active_record'
require 'db/models/game'
require 'db/models/event'
require 'db/models/event_type'
require 'db/models/flag'
require 'db/models/player'
  
   class Init < ActiveRecord::Migration  
     def self.up  
       
			create_table :games do |table|
				table.column :datetime, :datetime
				table.column :duration, :integer
				table.column :flags, :boolean
			end
		

		
		
			create_table :players do |table|
				table.column :name, :string
			end
		
		
		
			create_table :flags do |table|
				table.column :acronym, :string
				table.column :name, :string
			end
			DB::Flag.create :id => 1,  :acronym => "no",:name => "Bare muzzle"
			DB::Flag.create :id => 2,  :acronym => 'A' ,:name => 'Agility'
			DB::Flag.create :id => 3,  :acronym => 'BU',:name => 'Burrow'
			DB::Flag.create :id => 4,  :acronym => 'CL',:name => 'Cloak'
			DB::Flag.create :id => 5,  :acronym => 'G' ,:name => 'Genocide'
			DB::Flag.create :id => 6,  :acronym => 'GM',:name => 'Guided Missle'
			DB::Flag.create :id => 7,  :acronym => 'ID',:name => 'Identify'
			DB::Flag.create :id => 8,  :acronym => 'IB',:name => 'Invisible Bullet'
			DB::Flag.create :id => 9,  :acronym => 'L' ,:name => 'Laser'
			DB::Flag.create :id => 10, :acronym => 'MG',:name => 'Machine Gun'
			DB::Flag.create :id => 11, :acronym => 'MQ',:name => 'Masquerade'
			DB::Flag.create :id => 12, :acronym => 'N' ,:name => 'Narrow'
			DB::Flag.create :id => 13, :acronym => 'OO',:name => 'Oscilation Overthruster'
			DB::Flag.create :id => 14, :acronym => 'PZ',:name => 'Phantom Zone'
			DB::Flag.create :id => 15, :acronym => 'QT',:name => 'Quick Turn'
			DB::Flag.create :id => 16, :acronym => 'F' ,:name => 'Rapid Fire'
			DB::Flag.create :id => 17, :acronym => 'SE',:name => 'Seer'
			DB::Flag.create :id => 18, :acronym => 'SH',:name => 'Shield'
			DB::Flag.create :id => 19, :acronym => 'SW',:name => 'Shockwave'
			DB::Flag.create :id => 20, :acronym => 'ST',:name => 'Stealth'
			DB::Flag.create :id => 21, :acronym => 'SR',:name => 'Steamroler'
			DB::Flag.create :id => 22, :acronym => 'SB',:name => 'Super Bullet'
			DB::Flag.create :id => 23, :acronym => 'T' ,:name => 'Tiny'
			DB::Flag.create :id => 24, :acronym => 'TH',:name => 'Thief'
			DB::Flag.create :id => 25, :acronym => 'US',:name => 'Useless'
			DB::Flag.create :id => 26, :acronym => 'V' ,:name => 'High Speed'
			DB::Flag.create :id => 27, :acronym => 'WG',:name => 'Wings'
                        
			create_table :event_types do |table|
				table.column :name, :string
			end         
			DB::EventType.create :id => 1, :name => 'join'
			DB::EventType.create :id => 2, :name => 'lave'
			DB::EventType.create :id => 3, :name => 'kill'
			DB::EventType.create :id => 4, :name => 'grab'
			DB::EventType.create :id => 5, :name => 'drop'
			DB::EventType.create :id => 6, :name => 'shoot'
			DB::EventType.create :id => 7, :name => 'jump'
			DB::EventType.create :id => 8, :name => 'suicide'


			create_table :events do |table|
				table.column :event_type_id, :integer
				table.column :datetime, :datetime
				table.column :game_id, :integer
				table.column :player_id, :integer
				table.column :target_id, :integer
				table.column :flag_id, :integer
			end
     end  
      
      def self.down  
        drop_table :games  
		drop_table :players
		drop_table :flags
		drop_table :events_types
		drop_table :events
     end  
   end  
